define(['text!service/myAppliances.html', '../service/data/appliancesList'],
	function(viewTemplate, Appliances) {
		return Piece.View.extend({
			id: 'service_myAppliances',

			events: {
				"click .delete": "deleteA",
				"click #add": "add",
			},
			render: function() {
				$(this.el).html(viewTemplate);

				Piece.View.prototype.render.call(this);
				return this;
			},
			onShow: function() {
				//write your business logic here :)
				console.info(Appliances);

				var windowHeight = $(window).height();
				var elTop = $("#appliances").offset().top;

				console.info(elTop);
				var elHeight = windowHeight - elTop;

				console.info(elHeight);
				$("#appliances").css({
					"height": elHeight
				});
				new iScroll($("#appliances")[0]);
				this.TempviewlateRender(Appliances);


			},

			deleteA: function(e) {
				var el = e.currentTarget;
				// var state = $(el).attr('state');
				console.info($(el).parent());
				$(el).parent().parent().remove();

			},
			add: function() {
				this.container.navigateForResult('/service/addAppliances', {
					trigger: true
				}, 'service/myAppliances', this.onGotResult);

			},

			//模板页面渲染

			TempviewlateRender: function(data) {

				var listTemplateWiki = _.template($("#appliancesTemp").html(), {
					"rows": data.rows
				});

				$("#appliancesList").append(listTemplateWiki);


				// new iScroll($("#standards"));
			},
		}); //view define

	});